<button class="btn btn-success btn-sm" data-toggle="modal" data-target="#exampleModal2">新增客户</button>

<div class="modal fade" id="exampleModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModal2"
     aria-hidden="true">
    <div class="modal-dialog modal-xs">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 36px;">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">新增客户</h4>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">客户名</label>
                    <input type="text" name="customerName" class="form-control" placeholder="请输入客户名">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">年龄</label>
                    <input type="number" name="age" maxlength="2" class="form-control" placeholder="请输入年龄">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">性别</label>
                    <select class="form-select form-control" name="customerGender">
                        <option value="0">女</option>
                        <option value="1">男</option>
                    </select>
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">手机号</label>
                    <input type="text" name="customerMobile" maxlength="11" class="form-control"
                           placeholder="请输入手机号">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">微信</label>
                    <input type="text" name="customerWechat" class="form-control" placeholder="请输入微信">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">信息来源</label>
                    <select class="form-select form-control" name="informationResources">
                        <option value="0">新媒体平台</option>
                        <option value="1">号码抓取</option>
                        <option value="2">朋友介绍</option>
                        <option value="3">外部接口数据分配</option>
                        <option value="4">其他</option>
                    </select>
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">{{ __('customer.customerAddress') }}</label>
                    <input type="text" name="customerAddress" class="form-control" placeholder="请输入地址">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">备注</label>
                    <textarea name="remark" class="form-control" placeholder="请输入备注"></textarea>
                </div>
{{--                <div class="mb-3">--}}
{{--                    <label for="exampleFormControlInput1" class="form-label">业务员</label>--}}
{{--                    <select name="operatorId" class="form-control">--}}
{{--                        @if(!empty($data))--}}
{{--                            @foreach ($data as $value)--}}
{{--                                <option value="{{ $value['user_id'] }}">{{ $value['name'] }}</option>--}}
{{--                            @endforeach--}}
{{--                        @endif--}}
{{--                    </select>--}}
{{--                </div>--}}
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="customerCreate()">提交</button>
            </div>
        </div>
    </div>
</div>
<script>
    function customerCreate() {
        if($("input[name='age']").val() > 99) alert('年龄不能超出99');
        ajaxPostFunc('/admin/ajax/customerCreate', {
            customer_name: $("input[name='customerName']").val(),
            age: $("input[name='age']").val(),
            customer_gender: $("select[name='customerGender']").val(),
            customer_mobile: $("input[name='customerMobile']").val(),
            customer_wechat: $("input[name='customerWechat']").val(),
            customer_qq: $("input[name='customerQq']").val(),
            education: $("select[name='education']").val(),
            information_resources: $("select[name='informationResources']").val(),
            // operator_id: $("select[name='operatorId']").val(),
            customer_address: $("input[name='customerAddress']").val(),
            remark: $("textarea[name='remark']").val(),
            _token: $.admin.token
        }, {}, res => {
            console.log(res);
            window.location.reload();
        });
    }
</script>
